package xcu.lxj.nettychat.common.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import xcu.lxj.nettychat.common.interceptor.CollectorInterceptor;
import xcu.lxj.nettychat.common.interceptor.TokenInterceptor;

/**
 * @Author XinJian Lei
 * @Date 2024/10/2 14:51
 * @Version 1.0
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private TokenInterceptor tokenInterceptor;
    @Autowired
    private CollectorInterceptor collectorInterceptor;


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/**").excludePathPatterns(
                "/swagger-ui/**",
                "/v3/api-docs/**",
                "/doc.html",
                "/webjars/**"
        );
        registry.addInterceptor(collectorInterceptor)
                .addPathPatterns("/**").excludePathPatterns(
                "/swagger-ui/**",
                "/v3/api-docs/**",
                "/doc.html",
                "/webjars/**"
        );
    }

}
